Fix(router-cli): Fixes on Windows and Improvements #717
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request addresses the following changes:
(fix) Fixed backslash on Windows:
(fix) Sanitized routePaths, import, and interface keys:
(enhanced) Made the parent search recursive:
(question) Layout Generation:
In the current project structure, we are using a pattern where there are separate files for layouts and index routes, leading to some complexities when organizing routes, especially when considering sub-routes within folders.
Current Project Structure:
posts.tsx
is the layout for the route /posts and generates a key with/posts/
.posts.index.ts
is the actual/posts
route and generates the key/posts
(without the last forward slash).posts.$postId.tsx
is the route that matches the postId property and generates the key/posts/$postId
.At least, this is what I had understood.
Challenges with the Current Approach:
Complexity when organizing routes, especially sub-routes within folders.
Odd generation behavior when attempting to place the last two files (posts.index.ts and posts.$postId.tsx) inside a folder called "posts". (I will retry getting this behavior asap with a brand new project).
Proposed Alternative Approach:
I propose an alternative approach to simplify route and layout generation:
Create a folder for the main route, e.g., posts. Inside the folder, have an
index.tsx
file, which would serve as both the layout for the main route and the actual/posts
route. Also inside the folder, have a$postId.tsx
file for routes that match thepostId
property. This file should generate the key/posts/$postId
.Benefits of the Alternative Approach:
Simplified organization: All related routes for a specific section are contained within a single folder, making it intuitive and organized.
Clear route generation: Each route file generates a key that directly corresponds to its URL path, eliminating confusion and redundancy.
I'm open to discussing this alternative approach with the team to gather insights and feedback.
I look forward to hearing your thoughts and suggestions on this proposed change.